package team.future.joke.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import team.future.joke.entity.WeixinConfig;
import team.future.joke.service.WeixinService;

import com.alibaba.fastjson.JSONObject;

/**
 * Title: SharejrController.java<br>
 * Description: <br>
 * Copyright (c) 未来工作室版权所有 2015    <br>
 * Create DateTime: 2015年9月23日 下午4:27:08 <br>
 * @author futurezhu
*/
@Controller
public class SharejrController {
	/**
	 * 微信接入回调
	 */
	@Autowired
	private WeixinService weixinService;

	@RequestMapping("/joke/weixin")
	@ResponseBody
	public String weixinjr(@RequestParam(value = "signature", defaultValue = "") String signature,
			@RequestParam(value = "timestamp", defaultValue = "") String timestamp,
			@RequestParam(value = "echostr", defaultValue = "") String echostr,
			@RequestParam(value = "token", defaultValue = "") String token,
			@RequestParam(value = "nonce", defaultValue = "") String nonce) {
		return echostr;
	}

	@RequestMapping("/joke/weixin/signature")
	@ResponseBody
	public String genratesignature() {
		WeixinConfig config = weixinService.getWeixinConfig();
		return JSONObject.toJSONString(config);
	}

	/**
	 * 微博取消接入回调
	 * @param source  appid
	 * @param uid  用户id
	 * @param auth_end 取消时间
	 * @return
	 */
	@RequestMapping("/joke/weibo/qxjr")
	@ResponseBody
	public String weiboqxjr(@RequestParam(value = "source", defaultValue = "") String source,
			@RequestParam(value = "uid", defaultValue = "") String uid,
			@RequestParam(value = "auth_end", defaultValue = "") String auth_end) {
		return "";
	}

	/**
	 * 微博接入回调
	 * @return
	 */
	@RequestMapping("/joke/weibo/jr")
	@ResponseBody
	public String weibojr() {
		return "Auth 2.0";
	}
}
